home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / DLLCust_Files / AXON / BKBIASA.C < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-08  |  1.3 KB  |  43 lines

  1. // Dynamic link library implementation of NeuroSolutions BackLinearAxon component using the performBackAxon protocol
  2.  
  3. #include "NSDLL.h" 
  4.  
  5. /* Backpropagation of component */
  6.  
  7. __declspec(dllexport) void performBackAxon(
  8.     void    *instance,    // Pointer to instance data
  9.     void    *dualInstance,    // Pointer to the forward axons instance data
  10.     NSFloat    *data,         // Pointer to the layer of processing elements (PEs)
  11.     int     rows,        // Number of rows of PEs in the layer
  12.     int     cols,        // Number of columns of PEs in the layer
  13.     NSFloat    *error         // Pointer to the sensitivity vector
  14.     )
  15. {
  16.     int i,length=rows*cols;
  17.     NSFloat *gradient = getWeights(instance);
  18.  
  19.     for (i=0; i<length; i++)
  20.         gradient[i] += error[i]; 
  21. }
  22.  
  23. /******************************************/
  24. /* Management of instance data (OPTIONAL) */
  25.  
  26. __declspec(dllexport) DLLData *allocBackAxon(
  27.     DLLData    *oldInstance,    // Pointer to the last instance if reallocating 
  28.     DLLData    *dualInstance,    // Pointer to forward axonÆs instance data (may be NULL)
  29.     int     rows,            // Number of rows of PEs in the layer
  30.     int     cols            // Number of columns of PEs in the layer
  31.     )
  32. {
  33.     DLLData *instance = allocDLLInstance(oldInstance);
  34.     setWeights(instance, rows*cols);
  35.     return instance;
  36. }
  37.  
  38. __declspec(dllexport) void freeBackAxon(DLLData *instance)
  39. {
  40.     freeDLLInstance(instance);
  41. }
  42.  
  43.